//
//  SXDataCheckManager.m
//  iOS_Router_Runtime
//
//  Created by 王水鑫 on 2019/1/1.
//  Copyright © 2019年 王水鑫. All rights reserved.
//

#import "SXDataCheckManager.h"

@implementation SXDataCheckManager

// 谓词匹配
+ (BOOL)predicateMatchesRuleWithRegex:(NSString *)regex evaluateWithObject:(nullable id)object {
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    return [predicate evaluateWithObject:object];
}

// 判断字符是否是中文
+ (BOOL)checkChineseFromCharacter:(NSString *)character {
    NSString *regex = @"(^[\u4e00-\u9fa5]+$)";
    return [SXDataCheckManager predicateMatchesRuleWithRegex:regex evaluateWithObject:character];
}

// 邮件正则判定
+ (BOOL)checkNormalEmailFormatFromString:(NSString *)string {
    NSString *regex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    return [SXDataCheckManager predicateMatchesRuleWithRegex:regex evaluateWithObject:string];
}

@end
